package pers.vic.dubbo.provider.conig;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.SessionRepository;
import org.springframework.session.data.redis.config.ConfigureRedisAction;
import pers.vic.dubbo.common.tool.SpringSessionUtil;

/**
 * 描述:
 * @author Vic.xu
 * @date 2022-01-25 10:54
 */
@Configuration
public class CommonConfig {

    @Bean
    @ConditionalOnMissingBean
    public SpringSessionUtil springSessionUtil(SessionRepository<?> sessionRepository) {
        return new SpringSessionUtil(sessionRepository);
    }

    /**
     *  解决redis集群环境没有开启Keyspace notifications导致的
     *
     *  Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource
     *
     * */
    @Bean
    public static ConfigureRedisAction configureRedisAction() {
        return ConfigureRedisAction.NO_OP;
    }
}
